home *** CD-ROM | disk | FTP | other *** search
- #include "rectpie.h"
-
-
- /* Rectangle */
-
- polyBaseThiS_0_def(RT,Shape,Rectangle)
-
- vFt_def(Rectangle,Shape) = {
- vF_value(RT,SH,show),
- vF_value(RT,SH,destruct)
- };
-
- vf_def(void,RT,SH,show,(Shape * thiS, int xxpose,
- int yxpose, unsigned scale))
- {
- Rectangle * RTthiS = SH_RectangleThiS(thiS);
- int poly[10];
- int dw = (int)(RTthiS->width/2*scale);
- int dh = (int)(RTthiS->heighth/2*scale);
- /*lint -e506 */
- int l = (int)RT_getx(RTthiS)+xxpose - dw;
- int t = (int)RT_gety(RTthiS)+yxpose - dh;
- int r = (int)RT_getx(RTthiS)+xxpose + dw;
- int b = (int)RT_gety(RTthiS)+yxpose + dh;
- /*lint +e506 */
- poly[0] = l; poly[1] = t;
- poly[2] = r; poly[3] = t;
- poly[4] = r; poly[5] = b;
- poly[6] = l; poly[7] = b;
- poly[8] = l; poly[9] = t;
-
- drawpoly(5,poly);
- }
-
- vf_def(void,RT,SH,destruct,(Shape * thiS,
- unsigned nobj, int malloced))
- {
- struct_destruct(RT,SH_RectangleThiS(thiS),
- nobj,malloced);
- }
-
- struct_initVFTs_def(RT,(Rectangle * thiS,
- void * descendanT_0
- , vFT_0_decl(Shape)))
- {
- poly_assign(thiS,descendanT_0);
- struct_initVFTs(SH,
- (RT_ShapeThiS(thiS), (void *) thiS,
- vFT_0_name(Shape)));
- }
-
- struct_init_def(Rectangle,RT,_,
- (Rectangle * thiS_0, unsigned nobj,
- unsigned width, unsigned heighth,
- unsigned x, unsigned y))
- {
- unsigned i, fail;
- int malloced = 0;
-
- if (!nobj)
- return (Rectangle *)0;
- if (!thiS_0) if ((thiS_0 = (Rectangle *)
- RT_malloc(nobj))
- == (Rectangle *)0)
- return (Rectangle *)0;
- else
- malloced = 1;
- for (i = fail = 0; i < nobj; i++) {
- if (!struct_init(SH,_,(RT_ShapeThiS(&thiS_0[i]),
- 1,(x?x:width/2),(y?y:heighth/2)))) {
- fail = 1;
- break;
- }
- struct_initVFTs(RT,(&thiS_0[i], (void *)0,
- vFT_value(Rectangle,Shape)));
-
- thiS_0[i].width = width;
- thiS_0[i].heighth = heighth;
-
- } /* for */
-
- if (fail) {
- /*
- All indices >= "i" have already been destructed
- as required. Indices i-1 to 0 are now
- destructed via the destructor since we're
- inside the constructor of the instance level if
- i > 0. Remember that if this is an
- intermediate constructor call that i == 0
- and malloced == 0 always so no further
- processing is required at this level and NULL
- is returned to the calling level constructor.
- */
- if (i)
- struct_destruct(RT,thiS_0,i,malloced);
- else if (malloced)
- RT_free(thiS_0);
- return (Rectangle *) 0;
- }
-
- return thiS_0;
- }
-
- struct_destruct_def(Rectangle,RT)
- {
- unsigned i;
-
- if (!thiS_0 || !nobj)
- return;
-
- for (i = nobj; i--; /* no reinit */) {
-
- struct_initVFTs(RT,(&thiS_0[i], (void *)0,
- vFT_value(Rectangle,Shape)));
-
- struct_destruct(SH,RT_ShapeThiS(&thiS_0[i]),1,0);
-
- }
-
- if (malloced)
- RT_free(thiS_0);
- }
-
-
- /* PieSlice */
-
- polyBaseThiS_0_def(PS,Shape,PieSlice)
-
- vFt_def(PieSlice,Shape) = {
- vF_value(PS,SH,show),
- vF_value(PS,SH,destruct)
- };
-
- vf_def(void,PS,SH,show,(Shape * thiS, int xxpose,
- int yxpose, unsigned scale))
- {
- PieSlice * PSthiS = SH_PieSliceThiS(thiS);
-
- /*lint -e506 */
- pieslice((int)PS_getx(PSthiS)+xxpose,
- (int)PS_gety(PSthiS)+yxpose,
- (int)PSthiS->startAngle,
- (int)PSthiS->endAngle,
- (int)(PS_CircleThiS(PSthiS)
- ->radius*scale));
- /*lint +e506 */
- /* radius is in Circle protected scope so it
- is accessible from PieSlice */
- }
-
- vf_def(void,PS,SH,destruct,(Shape * thiS,
- unsigned nobj, int malloced))
- {
- struct_destruct(PS,SH_PieSliceThiS(thiS),
- nobj,malloced);
- }
-
- struct_initVFTs_def(PS,(PieSlice * thiS,
- void * descendanT_0
- , vFT_0_decl(Shape)))
- {
- poly_assign(thiS,descendanT_0);
- struct_initVFTs(CR,
- (PS_CircleThiS(thiS), (void *) thiS,
- vFT_0_name(Shape)));
- }
-
- struct_init_def(PieSlice,PS,_,
- (PieSlice * thiS_0, unsigned nobj,
- unsigned startAngle,
- unsigned endAngle,
- unsigned radius,
- unsigned x, unsigned y))
- {
- unsigned i, fail;
- int malloced = 0;
-
- if (!nobj)
- return (PieSlice *)0;
- if (!thiS_0) if ((thiS_0 = (PieSlice *)
- PS_malloc(nobj))
- == (PieSlice *)0)
- return (PieSlice *)0;
- else
- malloced = 1;
- for (i = fail = 0; i < nobj; i++) {
- if (!struct_init(CR,_,(PS_CircleThiS(&thiS_0[i]),
- 1,radius,x,y))) {
- fail = 1;
- break;
- }
- struct_initVFTs(PS,(&thiS_0[i], (void *)0,
- vFT_value(PieSlice,Shape)));
-
- thiS_0[i].startAngle = startAngle;
- thiS_0[i].endAngle = endAngle;
-
- } /* for */
-
- if (fail) {
- /*
- All indices >= "i" have already been destructed
- as required. Indices i-1 to 0 are now
- destructed via the destructor since we're
- inside the constructor of the instance level if
- i > 0. Remember that if this is an
- intermediate constructor call that i == 0
- and malloced == 0 always so no further
- processing is required at this level and NULL
- is returned to the calling level constructor.
- */
- if (i)
- struct_destruct(PS,thiS_0,i,malloced);
- else if (malloced)
- PS_free(thiS_0);
- return (PieSlice *) 0;
- }
-
- return thiS_0;
- }
-
- struct_destruct_def(PieSlice,PS)
- {
- unsigned i;
-
- if (!thiS_0 || !nobj)
- return;
-
- for (i = nobj; i--; /* no reinit */) {
-
- struct_initVFTs(PS,(&thiS_0[i], (void *)0,
- vFT_value(PieSlice,Shape)));
-
- struct_destruct(CR,PS_CircleThiS(&thiS_0[i]),1,0);
-
- }
-
- if (malloced)
- PS_free(thiS_0);
- }
-